/*
 * @Author: humengchuan 531537052@qq.com
 * @Date: 2024-11-11 11:47:00
 * @LastEditors: humengchuan 531537052@qq.com
 * @LastEditTime: 2024-11-11 17:44:40
 * @FilePath: \project\work-tool\experi-api\utils\responses.js
 * @Description: 
 */
const createError = require('http-errors'); 

function success(res, data, msg, code) {

}

function failure(res, error) {
  let errorMsg = error.message || '系统错误'
  let errorCode = error.code || 500

  res.status(errorCode).json({
    code: errorCode,
    msg: `请求失败：${error}`,
    error: Array.isArray(errorMsg) ? errorMsg : [errorMsg]
  })
}


module.exports = {
  success,
  failure
}